package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.RoleSearchCond;
import com.java.control.search.SearchStat;
import com.java.entity.Role;
import com.java.service.RoleService;

/**
 * 角色管理
 * @author wqf
 * @version  Nov 24, 2011 12:00:53 PM
 */
public class RoleListController extends AbstractAdminCommandController {

	public RoleListController(){
		this.setCommandClass(RoleSearchCond.class);
	}	

	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		RoleSearchCond searchCond = (RoleSearchCond)command;
		
		ModelAndView mav = new ModelAndView(this.view);
		searchCond.setPageSize(10L);
		SearchStat searchStat=this.roleService.getSearchStat(Role.class, searchCond);
		List<Role> list=this.roleService.search(Role.class,searchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);
		mav.addObject("roleList", list);		
				
		return mav;
		
	}
		
	private String view;
	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}

	private RoleService roleService;

	public void setView(String view) {
		this.view = view;
	}
}
